
from pages.base_page import BasePage
from selenium.webdriver.common.by import By

class ClueHomePage(BasePage):
    url = '/crm/index.php?m=leads'
    clue_add_locator = (By.LINK_TEXT, '新建线索')
    clue_whatis_locator = (By.LINK_TEXT, '什么是线索池？')
    first_clue_view_locator = (By.XPATH,'/html/body/div[5]/div[2]/div[2]/form/table/tbody/tr[1]/td[12]/a[1]')
    first_clue_locator = (By.XPATH,'/html/body/div[5]/div[2]/div[2]/form/table/tbody/tr[1]/td[12]/a[3]')
    check_first_clue_locator = (By.XPATH,'/html/body/div[5]/div[2]/div[2]/form/table/tbody/tr[1]/td[1]/input')
    click_batch_operate_locator = (By.XPATH,'/html/body/div[5]/div[2]/div[1]/ul/li[1]/div/a')
    click_batch_del_locator = (By.ID,'delete')
    del_success_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    recycle_bin_locator = (By.CSS_SELECTOR,'body > div.container > p > a:nth-child(17)')
    clue_pool_locator = (By.CSS_SELECTOR,'body > div.container > div.page-header > ul > li:nth-child(2) > a')

    # 点击新建线索
    def click_add_clue(self):
        self.driver.find_element(*self.clue_add_locator).click()
    # 点击查看第一个线索
    def click_first_clue_view(self):
        self.driver.find_element(*self.first_clue_view_locator).click()
    #点击编辑第一个线索
    def edit_first_clue(self):
        self.driver.find_element(*self.first_clue_locator).click()
    #选择勾选第一个线索
    def check_first_clue(self):
        self.driver.find_element(*self.check_first_clue_locator).click()
    #点击批量操作
    def click_batch_operate(self):
        self.driver.find_element(*self.click_batch_operate_locator).click()
    #点击批量删除
    def click_batch_del(self):
        self.driver.find_element(*self.click_batch_del_locator).click()

    #返回删除成功的提示信息
    def del_success(self):
        return self.driver.find_element(*self.del_success_locator).text
    #点击进入回收站
    def enter_recycle_bin(self):
        self.driver.find_element(*self.recycle_bin_locator).click()
    #点击进入线索池
    def enter_clue_pool(self):
        self.driver.find_element(*self.clue_pool_locator).click()





